<?php
namespace app\common\Logic;
use Payment\Common\PayException;
use Payment\Notify\PayNotifyInterface;
use Payment\Config;

class Notify implements PayNotifyInterface
{
    public function notifyProcess(array $data)
    {
        model('DebugLog')->addLog($data, 'notify data');
        $channel = $data['channel'];
        if ($channel === Config::ALI_CHARGE) {// 支付宝支付
            if ($data['trade_state'] == 'success') { // 支付成功
                model('order')->notify($data['order_no'], $data['transaction_id'], $data['amount'], 2, $data);
            }
        } elseif ($channel === Config::WX_CHARGE) {// 微信支付
            if ($data['trade_state'] == 'success') { // 支付成功
                model('order')->notify($data['order_no'], $data['transaction_id'], $data['amount'], 3, $data);
            }
        } elseif ($channel === Config::CMB_CHARGE) {// 招商支付
        } elseif ($channel === Config::CMB_BIND) {// 招商签约
        } else {
            // 其它类型的通知
        }
        // 执行业务逻辑，成功后返回true
        return true;
    }
}
